#include <stdio.h>
#include <iostream>
#include <fstream>
#include <log.hpp>
#include <memfs.h>

CLog clg;

extern "C" int MAIN(int argc, char **argv)
{
  Mfs fs;
  Mshell shell(fs);
  char *name;

  if (argc < 3)
  {
    clg.err() << "Usage: " << argv[0] << " <src1> <src2> [output]"
	      << std::endl;
    return -1;
  }
  else if (argc < 4)
  {
    name = "/dev/stdout";
  }
  else
  {
    name = argv[3];
  }

  std::ifstream if1(argv[1]);
  XMLParser xp1(if1);
  shell.Import(xp1, "/");
  
  std::ifstream if2(argv[2]);
  XMLParser xp2(if2);
  shell.Import(xp2, "/");

  std::ofstream of(name);
  XMLParser xp3(of);
  shell.Export(xp3, "/");
  
  return 0;
}
